#ifndef PAGEDATAANALYSIS_H
#define PAGEDATAANALYSIS_H

#include <QWidget>
#include <QtCharts>
#include "core/databasepool/databasepool.h"
#include "modules/data-monitor/datamonitor.h"
#include "dataanalysis.h"
#include "alertmanager.h"

QT_CHARTS_USE_NAMESPACE

namespace Ui {
class pageDataAnalysis;
}

class pageDataAnalysis : public QWidget
{
    Q_OBJECT

public:
    explicit pageDataAnalysis(QWidget *parent = nullptr);
    ~pageDataAnalysis();

private slots:
    void on_btnAnalyze_clicked();
    void on_btnGenerateReport_clicked();
    void updateAlertTable();

private:
    Ui::pageDataAnalysis *ui;
    DataAnalysis *m_dataAnalysis;
    AlertManager *m_alertManager;
    QChart *m_chart;
    QLineSeries *m_temperatureSeries;
    QLineSeries *m_humiditySeries;
    QDateTimeAxis *m_axisX;
    QValueAxis *m_axisY;
    DataMonitor *m_dataMonitor;

    void setupChart();
    void loadAlarmData();
    void showStatistics(const QList<QSqlRecord>& records);
};

#endif // PAGEDATAANALYSIS_H
